

//Settings Global
//Webservices URLs
var webserviceUrl = "http://localhost:8080/Server/rest/";
var entriesUrl = "entries";
var categoriesUrl = "entries/categories";
var authUrl = "auth";
var dailyUrl = "daily";

var isLoggedIn = false;

MyApp = new Backbone.Marionette.Application();


//MyApp Instanciation

MyApp.addRegions({
    sidebar: "#sidebarRegion",
    main: "#mainRegion",
    header: "#headerRegion",
    footer: "#footerRegion"
});


MyApp.addInitializer(function (options) {

    MyApp.navBarView = new NavBarView();
    MyApp.sideBarView = new SidebarView();
    MyApp.user = new User();

});

//Startup Method (similar to main())
MyApp.on('start', function () {
    console.log("MyApp:on:start start...");
    //Re-Route to default start page
    console.log("MyApp:on:start stop.");
});

//Subscribers to the Modules

MyApp.vent.on('LoginModule:success', function () {
    console.log("MyApp:on:LoginModule:success start...");

    MyApp.main.close();
    MyApp.header.show(MyApp.navBarView);
    MyApp.sidebar.show(MyApp.sideBarView);
    MyApp.module("NewEntryModule").start(MyApp.main);

    console.log("MyApp:on:LoginModule:success stop.");
});

$(document).ready(function () {

    console.log("document:ready start...");

    MyApp.start();
    document.location.href = websiteUrl + "#/login";
    console.log(appRouter);
    console.log("document:ready stop.");

});